﻿using SachOnlineLibrary.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UC_Admin_UCQLTaiKhoan : System.Web.UI.UserControl
{
    TaiKhoanDAL taikhoan = new TaiKhoanDAL();
    DangKiBLL tk = new DangKiBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gvThanhVien.DataSource = tk.LietKeTatCaTK();
            gvThanhVien.DataBind();
        }
    }
    public string CheckTrangThai(object obj)
    {
        bool b = bool.Parse(obj.ToString());

        if (b)
            return "Đã kích hoạt";
        else
            return "Chưa kích hoạt";
    }
    protected void gvThanhVien_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        bool trangthai = false;
        int ma = int.Parse(gvThanhVien.Rows[e.RowIndex].Cells[0].Text.ToString());       
        if (((CheckBox)gvThanhVien.Rows[e.RowIndex].FindControl("CheckBox1")).Checked)    
            trangthai = false;        
        else       
            trangthai = true;        
        if (tk.KichHoatTK(ma, trangthai) == true)
        {           
            gvThanhVien.DataSource = tk.LietKeTatCaTK();
            gvThanhVien.DataBind();           
        }
        else
        {
            
        }
    }
}